#ifndef PLINTH_INTERNAL_CONSOLE_H
#define PLINTH_INTERNAL_CONSOLE_H

#include "Core.h"
#include "AbstractObject.h"

class SimpleConsoleHelper : public Console
{
public:
	// these are called from core
	void sendMessage(const std::string& message);
	std::vector<std::string> receiveMessages();

	std::vector<std::string> getOutputMessages();
	void executeCommand(std::string& command);

	bool hasOutput();
private:
	std::vector<std::string> _outMessages;
	std::vector<std::string> _cmdMessages;
};

class InternalConsole : public AbstractObject
{
public:
	InternalConsole();
	~InternalConsole();

	//OBJTYPE InternalConsole
	//LIAG_THESE
	void attach(int sheetId, int chanId);
	void detach();
	void addPrinter(AnyAOPtr printer);
	void removePrinter(AnyAOPtr printer);
	void executeCommand(std::string& cmd);
	//STOP_LIAG

	// Genero AbstractObject stuff below

	// Return the c++ type id
	int getCppTypeId();
	// Returns whether this can be cast to a given type
	bool isType(int id);

	// Return the c++ type as a string 
	std::string getCppTypeName();

	// returns a description of this thing
	std::string getDescription();

	// create another one of these
	AbstractObject* newInstance();

	// init & update
	void init();
	void update(double dt);

	// push its static functions into the given lua table
	void pushStaticFuncs(lua_State* L);
private:
	std::vector<AnyAOPtr> _printers;
	SimpleConsoleHelper* _simpleConsole;
	int _attachedSheet;
	int _attachedChannel;
};

#endif